<?php
/**
 * Created by PhpStorm.
 * User: Guojunchen
 * Date: 2018/4/12
 * Time: 10:36
 */

namespace app\common\lib\exception;
use think\exception\Handle;

class ApiHandleException extends Handle{

    public $httpCode = 500;

    public function render(\Exception $e){
        if (config('app_debug') == true){
            return parent::render($e);
        }
        if ($e instanceof ApiException){
            $this->httpCode = $e->httpCode;
        }
        return renderJson($e->getMessage(), 0);
    }
}